package cn.ctvonline.android.kaopu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;

import cn.ctvonline.android.kaopu.R;
import cn.ctvonline.android.kaopu.base.BaseActivity;
import cn.ctvonline.android.kaopu.base.IncomingHandler;
import cn.ctvonline.android.kaopu.base.MessageHandleListener;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 */
public class WelcomeActivity extends BaseActivity {
    private IncomingHandler<WelcomeActivity> hander;
    static final int WELCOME_FINISHED = 0x02;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
//        if(getSupportActionBar() != null){ getSupportActionBar().hide());
        initHandler();
        new Thread(new Runnable() {
            @Override
            public void run() {
                //各种检查
                try {
                    Thread.sleep(3000);
                    hander.sendEmptyMessage(WELCOME_FINISHED);
                } catch (Exception e) {

                }
            }
        }).start();
    }

    private void initHandler() {
        hander = getHandler();
        hander.setOnMessageHandleListener(new MessageHandleListener() {
            @Override
            public void onHandlerMessage(Message msg) {
                switch (msg.what) {
                    case WELCOME_FINISHED: {
                        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                        startActivity(intent);
                        finish();
                    }
                    break;
                }
            }
        });
    }

    @Override
    protected String generatePageName() {
        return "welcomeActivity pageName";
    }
}
